public class test1 {
    //力扣 268.丢失的数字
    public static void main(String[] args) {
        System.out.println(3^0^2^2^3);
    }
    //hash数组
    public int missingNumber1(int[] nums) {
        int[] hash = new int[nums.length+1];
        for(int n:nums){
            hash[n]++;
        }
        for(int i = 0;i<hash.length;i++){
            if(hash[i]==0){
                return i;
            }
        }
        return -1;
    }
    //求和相减
    public int missingNumber2(int[] nums) {
        int n = nums.length;
        int sum = (1+n)*n/2;
        int sum2 = 0;
        for(int x:nums){
            sum2+=x;
        }
        return sum- sum2;
    }
    //位运算(异或)
    public int missingNumber(int[] nums) {
        int ret = 0;
        for(int x:nums){
            ret^=x;
        }
        for(int i = 0;i<=nums.length;i++){
            ret^=i;
        }
        return ret;
    }
}
